<!--海外出库-拣货调度-->
<template>
  <div class="page-container">
    <page_breadcrumb :getKeyMethod="init_table_model" @change="change_table_model" />
    <ex_super_table_page v-bind="option" ref="SuperTablePage" @selection-change="e => selection = e">
      <template v-slot:action-right>
        <div class="flex_row">
          <el-button @click="createPickingTask" type="primary">
            {{ $tt('title_pick_scheduling') }}<i class="el-icon-thumb el-icon--right"></i>
          </el-button>
        </div>
      </template>
    </ex_super_table_page>
    <standard_create_waveRule ref="standard_create_waveRule" @afterSubmitSuccess="dialogCreatePickingTaskSubmit" />
    <!-- <detail_standard_outbound ref="detail_standard_outbound" /> -->
  </div>
</template>


<script>
import standard_create_waveRule from './dialog/standard_create_waveRule.vue';
// import detail_standard_outbound from '@/component/wms/detail_standard_outbound.vue';
import superTablePageFunction from '@/mixin/super-table-page-function';
import page_table_model_manage from '@/mixin/page_table_model_manage';
import emitOnFunction from '@/mixin/emit-on-function';
let emitKey = 'standard>picking_dispatch'

export default {
  title: "title_standard_picking_dispatch",
  mixins: [superTablePageFunction, emitOnFunction(emitKey), page_table_model_manage],
  components: { standard_create_waveRule, },
  data() {
    return {
      selection: [],
      option: {
        search: {
          model: [
            { label: "label_customer", key: "customerIds", type: "common_customer_choose", attrs: { multiple: true }, },

            { label: "label_outbound_code", key: "outOrderNo", },
            { label: "label_outbound_type", key: "type", type: 'select', enum: 'OutboundOrderTypeEnum' },
            { label: "label_outbound_method", key: "outboundMode", type: 'select', enum: 'OutboundOrderModeEnum' },
            { label: "label_ec_platform", key: "ecPlatformName", type: 'select', enum: 'OmsOutboundOrderEcPlatformEnum' },
            {
              label: "label_order_pick_type", key: "orderPickTypeList", type: 'select', enum: 'OutboundOrderStructureEnum',
              attrs: {
                placeholder: "tip_please_select_multiple",
                multiple: true,
              },
            },
            { label: "label_tms_common_carrier", key: "supplierName", },
            {
              label: "label_logistics", key: "logisticsId", type: 'select', fold: true,
              url: "/wms-api/base/WmsPmsProductRpc/selectTransportList.json",
              urlParams: { productType: "LAST_TRANSPORT" },
              option: { label: "productName", value: "id" }
            },

          ],
        },
        table: {
          url: "/wms-api/outbound/OutboundOverseasOrderRpc/selectByPage.json",
          urlParams: { wavePlanFlag: 'N', pickTaskFlag: 'N', status: 'WAIT_OUTBOUND' },
          model: this.init_table_model(),
        },
      },
    };
  },
  computed: {

  },

  mounted() {
  },
  props: {

  },

  methods: {
    option_table_model() {
      return [
        { type: 'selection', selectable: this.isSelectable, clickToggle: true, },

        { key: 'outOrderNo', label: 'label_outbound_code', 'min-width': 140, },
        { key: 'omsOrderNo', label: 'label_order_code', 'min-width': 120, },

        { key: 'customerName', label: 'label_customer_info', 'width': 120, 'show-overflow-tooltip': true, },
        { key: 'bizType', label: 'label_business_type', 'width': 120, formatter: (r, c, v) => this.$enumShow(v, "BizTypeEnum") },
        { key: 'outboundProductType', label: 'label_sku_outbound_request', 'width': 120, formatter: (r, c, v) => this.$enumShow(v, "OutboundProductTypeEnum") },
        { key: 'ecPlatformName', label: 'label_ec_platform', 'width': 120, formatter: (r, c, v) => this.$enumShow(v, "OmsOutboundOrderEcPlatformEnum") },
        { key: 'orderStructure', label: 'label_order_pick_type', formatter: (r, c, v) => this.$enumShow(v, "OutboundOrderStructureEnum"), 'width': 120, },
        { key: 'outboundMode', label: 'label_outbound_method', formatter: (r, c, v) => this.$enumShow(v, "OutboundOrderModeEnum"), 'width': 120, },
        { key: 'logisticsName', label: 'label_logistics', 'width': 120, },

        { key: 'skuCount', label: 'label_outbound_count', 'width': 100, },
        { key: 'wavePlanFlag', label: 'label_is_create_waveplan', 'width': 100, formatter: (r, c, v, i) => this.$enumShow(v, "YesOrNoEnum") },
        { key: 'pickTaskFlag', label: 'label_is_create_picktask', 'width': 100, formatter: (r, c, v, i) => this.$enumShow(v, "YesOrNoEnum") },
        { key: 'outType', label: 'label_outbound_type', 'width': 100, formatter: (r, c, v, i) => this.$enumShow(v, "OutboundOrderTypeEnum") },
        { key: 'outStatus', label: 'label_outbound_status', 'width': 100, formatter: (r, c, v, i) => this.$enumShow(v, "OutboundOrderStatusEunm") },

        { key: 'consignee', label: 'label_consignee_person_name', 'width': 100, 'show-overflow-tooltip': true, },
        { key: 'consigneePhone', label: 'label_consignee_person_phone', 'width': 100, 'show-overflow-tooltip': true, },
        {
          type: 'operate', operate: [
            { label: "label_view_detail", click: (row) => this.clickDetail(row) },
          ]
        },
      ]
    },
    isSelectable(row) {
      return row.wavePlanFlag != 'Y' && row.pickTaskFlag != 'Y'
    },
    createPickingTask() {
      let _list = this.selection
      if (_list.length == 0) {
        return this.$message.error(this.$tt('tip_please_select_order'))
      }
      if (_list.some(it => it.wavePlanFlag == 'Y')) {
        return this.$message.error(this.$tt('tip_select_order_has_create_waveplan'))
      }
      if (_list.some(it => it.pickTaskFlag == 'Y')) {
        return this.$message.error(this.$tt('tip_select_order_has_create_picktask'))
      }
      this.$refs['standard_create_waveRule'].show({ itemList: _list })
    },
    clickDetail(row) {

      // let title = `${this.$tt('label_outbound_code')}:${row.outOrderNo} / ${this.$tt('label_order_code')}:${row.omsOrderNo}`
      // this.$refs['detail_standard_outbound'].show({ params: { id: row.id }, title })

      this.$router.push({ path: '/page/wms/overseas/outbound/outbound_detail', query: { code: row.outOrderNo, id: row.id, } })
    },

    dialogCreatePickingTaskSubmit() {
      this.reload()
      this.$emitPage('standard>wave_plan_list', 'reload')
      this.$emitPage('standard>outbound_manage', 'reload')
      this.$emitPage('standard>picking_task_list', 'reload')
    },
  }
};

</script>
<style></style>
